﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using matrixdotnet.CommonDAL;
using matrixdotnet.Common;
using System.Data.Common;
using matrixdotnet.DBHelperLib;
using matrixdotnet.CommonDALImp;

namespace Cinema.DAL
{
    public interface IFilmDataEntity : IDataEntityL<FilmUniqueKey, IFilm>, IFilm
    {
    }
    // public class FilmDataEntity : DataEntityL<FilmUniqueKey, IFilm>, IFilm, IFilmDataEntity
    public class FilmDataEntity : MappedDataEntity<long, FilmUniqueKey, IFilm, FilmDataEntity>, IFilmDataEntity
    {
        // IFromFilmObjectMapper Mapper { get; set; }

        public FilmDataEntity(
            long identity, IFilm businessEntity, long version) :
            base(identity, businessEntity, version)
        {
            // Mapper = mapper;
        }

        public FilmDataEntity(IFilm businessEntity) :
            base(businessEntity)
        {
            // Mapper = mapper;
        }

        #region IFilm Members

        public string Name
        {
            get
            {
                return BusinessEntity.Name;
            }
            set
            {
                BusinessEntity.Name = value;
                OnDirty();
            }
        }

        public string Description
        {
            get
            {
                return BusinessEntity.Description;
            }
            set
            {
                BusinessEntity.Description = value;
                OnDirty();
            }
        }

        public string Director
        {
            get
            {
                return BusinessEntity.Director;
            }
            set
            {
                BusinessEntity.Director = value;
                OnDirty();
            }
        }

        public PositiveValue<short> Duration
        {
            get
            {
                return BusinessEntity.Duration;
            }
            set
            {
                BusinessEntity.Duration = value;
                OnDirty();
            }
        }

        public string ImagePath
        {
            get
            {
                return BusinessEntity.ImagePath;
            }
            set
            {
                BusinessEntity.ImagePath = value;
                OnDirty();
            }
        }

        public DateTime? DiscontinueDate
        {
            get
            {
                return BusinessEntity.DiscontinueDate;
            }
            set
            {
                BusinessEntity.DiscontinueDate = value;
                OnDirty();
            }
        }

        #endregion

        protected override FilmDataEntity TDataEntityCast
        {
            get { return this; }
        }

        /*
        protected override int UpdateEntity()
        {
            return Mapper.Update(this);
        }

        protected override long InsertEntity()
        {
            return Mapper.Insert(this);
        }

        protected override int DeleteEntity()
        {
            return Mapper.Delete(this);
        }
         * */
    }

    public class FilmLazyEntity : LazyDataEntityL<FilmUniqueKey, IFilm, IFilmDataEntity>, IFilm
    {
        public FilmLazyEntity(long identity, FilmDataMapper dataMapper) :
            base(identity, dataMapper)
        {
        }

        #region IFilm Members

        public string Name
        {
            get
            {
                return DataEntity.Name;
            }
            set
            {
                DataEntity.Name = value;
            }
        }

        public string Description
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string Director
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public PositiveValue<short> Duration
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string ImagePath
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public DateTime? DiscontinueDate
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }
}
